package com.bases {
	import com.Interface.IBase;
	import config.TConfig;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFieldType;
	import flash.text.TextFormat;

	//原版
	public class TTextInput extends TUIComponent implements IBase {
		public var sId:String;
		protected var txt:TextField;
		protected var format:TextFormat;

		public function TTextInput(type:Boolean = true){
			txt = new TextField();
			this.addChild(txt);
			txt.background = true;
			txt.backgroundColor = 0xffffff;
			txt.border = true;
			txt.borderColor = 0xaaaaaa;
			if (type){
				txt.type = TextFieldType.INPUT;
			}
		}

		public function set displayAsPassword(value:Boolean):void {
			this.txt.displayAsPassword = value;
		}

		override public function setSize(w:Number, h:Number):void {
			this.txt.width = w;
			this.txt.height = h;
		}

		public function set text(value:String):void {
			if (value == null){
				this.txt.text = "";
			} else {
				this.txt.text = value;
			}
		}

		public function get text():String {
			return this.txt.text;
		}

		public function set background(value:Boolean):void {
			txt.background = value;
		}

		public function set wordWrap(value:Boolean):void {
			txt.wordWrap = value;
		}

		public function set border(value:Boolean):void {
			this.txt.border = value;
		}

		public function set borderColor(value:uint):void {
			this.txt.borderColor = value;
		}

		public function set maxChars(value:int):void {
			this.txt.maxChars = value;
		}

		public function set focus(value:Boolean):void {
			if (value){
				TConfig.getInstance().stage.stage.focus = this.txt;
			} else {
				TConfig.getInstance().stage.stage.focus = null;
			}
		}

		/**
		 * 设置字体的大小
		 * @param fontSize
		 *
		 */
		public function set fontSize(fontSize:int):void {
			if (format == null){
				format = new TextFormat(null, fontSize);
			} else {
				format.size = fontSize;
			}
			this.txt.defaultTextFormat = format;
			this.txt.setTextFormat(format);
		}

		/**
		 * 设置字体的颜色
		 * @param color
		 *
		 */
		public function set fontColor(color:uint):void {
			if (format == null){
				format = new TextFormat(null, null, color);
			} else {
				format.color = color;
			}
			this.txt.defaultTextFormat = format;
			this.txt.setTextFormat(format);
		}

		//指定文本
		public function set restrict(value:String):void {
			this.txt.restrict = value
		}

		public function set enabled(value:Boolean):void {
			this.mouseEnabled = value;
			this.mouseChildren = value;
		}

		/**
		 * Dispose所有相关的对象
		 *
		 */
		override public function dispose():void {
			super.dispose();
			this.txt = null;
			this.format = null;
		}
	}
} //	
//}